home *** CD-ROM | disk | FTP | other *** search
/ Run Magazine ReRun: Strategy Games 1 / rerun-strategygamesI.d64 / chummy checker (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  5KB  |  208 lines

  1. 2 printchr$(147)"would you like instructions (y/n)?
  2. 4 [161] a$: [139] a$[179][177] "y" [175] a$[179][177]"n" [167] 4
  3. 6 [139] a$[178]"n" [167] 70
  4. 8 [153]"instructions on screen or printer (s/p)?
  5. 10 get b$: if b$<> "s" and b$<>"p" then 10
  6. 12 if b$="s"then  d=3
  7. 14 if b$="p" then d=4
  8. 16 open d,d
  9. 18 print#d,"
  10. 20 [152]d,"chummy checkers by tony brantner
  11. 24 print#d,"run it right: c-64; joystick
  12. 26 [152]d,"
  13. 28 print#d,"in this game, as in traditional
  14. 30 [152]d,"checkers, players must clear each
  15. 32 print#d,"other's pieces from the game by jumping
  16. 34 [152]d,"them. you can play against another
  17. 36 print#d,"person, against the computer, or watch
  18. 38 [152]d,"the computer play itself. a single joy-
  19. 40 print#d,"stick in port 2 controls both sides.
  20. 42 [152]d,"
  21. 44 print#d,"moving a piece involves two steps.
  22. 46 [152]d,"first, use the joystick to position the
  23. 48 print#d,"flashing yellow cursor over the piece
  24. 50 [152]d,"you want to move and press the fire-
  25. 52 print#d,"button. when a piece reaches your
  26. 54 [152]d,"opponent's back row it is kinged, and
  27. 56 print#d,"can move either forward or backward.
  28. 58 [152]d,"until then, it can only move forward.
  29. 60 print#d,"
  30. 62 [152]d,"enter zero as the number of players to
  31. 64 print#d,"put the computer in auto-play mode. f1
  32. 66 [152]d,"ends the game.
  33. 68 closed
  34. 70 print"press any key to begin the program..."
  35. 72 get e$:if e$="" then 72
  36. 74 clr
  37. 76 rem---checkers
  38. 78 poke52,56:poke56,56:clr
  39. 80 gosub372
  40. 82 v=53248:s1=54272:s2=s1+7:sc=1024:tc=646:a=rnd(-ti)
  41. 84 fora=1to38:sp$=sp$+chr$(32):next
  42. 86 dim bd(63),ch(1),mv$(1),d(1,3),tl(1),pl(1)
  43. 88 forz=0to63:bd(z)=sc+168+int(z/8)*80+(zand7)*3:next
  44. 90 ch(0)=163:ch(1)=171
  45. 92 mv$(0)=left$(sp$,4):mv$(1)="move"
  46. 94 d(0,0)=7:d(0,1)=9:d(0,2)=-7:d(0,3)=-9
  47. 96 fora=0to3:d(1,a)=-d(0,a):next
  48. 98 pokev+39,7:pokev+40,2
  49. 100 poke2040,13:poke2041,14
  50. 102 fora=s1tos1+24:pokea,0:next
  51. 104 pokes1+1,37:pokes1+5,9
  52. 106 pokes2+1,5:pokes2+5,8:pokes2+6,240:pokes1+24,15
  53. 108 gosub278
  54. 110 p1=0
  55. 112 rem---main
  56. 114 p2=p1:p1=1-p1:m=0
  57. 116 cy=10:cx=2:gosub354:poketc,1:printmv$(p1)
  58. 118 cx=34:gosub354:poketc,0:printmv$(p2)
  59. 120 ifpl(p1)then144
  60. 122 rem---computer
  61. 124 m1=1:forzz=0to63
  62. 126 ifpeek(bd(zz))=ch(p1)thengosub242
  63. 128 next:ifm1=1then192
  64. 130 ifm1<6thengosub228:goto138
  65. 132 gosub220:iftl(p2)=0then192
  66. 134 m1=1:zz=qd:gosub242
  67. 136 ifm1>=6then132
  68. 138 geta$:ifa$=chr$(133)then192
  69. 140 goto114
  70. 142 rem---player
  71. 144 r=p1*7:c=r:pokev+3,0
  72. 146 gosub200:ifa$=chr$(133)then192
  73. 148 ifpeek(l)<>ch(p1)then146
  74. 150 k=-(peek(l+1)=166)
  75. 152 pokev+2,peek(v):pokev+16,(peek(v+16)and1)*3:pokev+3,peek(v+1)
  76. 154 rf=r:cf=c:lf=l
  77. 156 gosub200:ifa$=chr$(133)then192
  78. 158 rem---test
  79. 160 ifr=rfandc=cfthen156
  80. 162 ifpeek(l)<>160then180
  81. 164 rm=rf-r:cm=cf-c:ifabs(rm)<>abs(cm)then180
  82. 166 ifk=0andsgn(rm)<>sgn(p1-.5)then180
  83. 168 ifabs(rm)=1andm=0thengosub228:goto114
  84. 170 ifabs(rm)<>2then180
  85. 172 rj=rf-rm/2:cj=cf-cm/2
  86. 174 lj=bd(rj*8+cj)
  87. 176 ifpeek(lj)=ch(p2)then188
  88. 178 rem---illegal move
  89. 180 ifmthen114
  90. 182 pokes2+4,33:fora=1to200:next
  91. 184 pokes2+4,32:goto144
  92. 186 rem---jump checker
  93. 188 gosub220:iftl(p2)then152
  94. 190 rem---end of game
  95. 192 q$="play again? [y/n] ":se$="yn":gosub326
  96. 194 ifa$="y"then108
  97. 196 poke832,0:sys832
  98. 198 rem---joystick
  99. 200 js=peek(56320)
  100. 202 geta$:ifa$=chr$(133)thenreturn
  101. 204 r=r+sgn(jsand1)-sgn(jsand2)and7
  102. 206 c=c+sgn(jsand4)-sgn(jsand8)and7
  103. 208 pokev,88+c*24and255:pokev+16,(peek(v+16)and2)-(c=7)
  104. 210 pokev+1,82+r*16
  105. 212 pokev+21,3:fora=1to90:next:pokev+21,0
  106. 214 ifjsand16then200
  107. 216 l=bd(r*8+c):return
  108. 218 rem---jump
  109. 220 fora=0to2
  110. 222 pokelj+a,160:pokelj+40+a,160:next
  111. 224 m=m+1:tl(p2)=tl(p2)-1:gosub314
  112. 226 rem---move
  113. 228 forz=0to2:pokel+z+s1,p1:pokel+40+z+s1,p1
  114. 230 pokel+z,peek(lf+z):pokel+40+z,peek(lf+40+z)
  115. 232 pokelf+z,160:pokelf+40+z,160:next
  116. 234 ifr=7orr=0thenk=1:pokel+1,166:pokel+41,167
  117. 236 pokes1+4,16:pokes1+4,17
  118. 238 return
  119. 240 rem---find computer move
  120. 242 kd=-(peek(bd(zz)+1)=166)
  121. 244 fordr=0to1+kd*2:m0=0
  122. 246 d=zz+d(p1,dr):ifd<0ord>63then274
  123. 248 f1=peek(bd(d)):f2=0:dj=d
  124. 250 d=d+d(p1,dr):ifd<0ord>63then254
  125. 252 f2=peek(bd(d))
  126. 254 iff1<>160then264
  127. 256 m0=2:d=dj:iff2<>ch(p2)thenm0=3
  128. 258 iff2=ch(p1)thenm0=4
  129. 260 if(d<8ord>55)andkd=0thenm0=5
  130. 262 goto270
  131. 264 iff1<>ch(p2)orf2<>160then274
  132. 266 m0=6:ifpeek(bd(dj)+1)=166thenm0=7
  133. 268 if(d<8ord>55)andkd=0thenm0=8
  134. 270 m0=m0+rnd(1)
  135. 272 ifm0>m1thenm1=m0:l=bd(d):lf=bd(zz):lj=bd(dj):r=int(d/8):qd=d
  136. 274 next:return
  137. 276 rem---screen
  138. 278 pokev+21,0:printchr$(147):poketc,1
  139. 280 printtab(15)" checkers ":zz=96
  140. 282 fora=0to63:forz=0to2
  141. 284 pokebd(a)+z,zz:pokebd(a)+40+z,zz
  142. 286 next
  143. 288 if(aand7)<7thenzz=160+(zz=160)*64
  144. 290 next
  145. 292 poketc,0:a$="#"
  146. 294 fora=1to3:gosub360:next
  147. 296 poketc,1:a$="+"
  148. 298 fora=6to8:gosub360:next
  149. 300 rem---get players
  150. 302 q$="players [0,1 or 2] ":se$="012":gosub326
  151. 304 pl(0)=0:pl(1)=0:a=val(a$)
  152. 306 ifathenpl(1)=1:pl(0)=a-1
  153. 308 cy=22:cx=9:gosub354:print"press  f1 [146] to end game"
  154. 310 tl(0)=12:tl(1)=12
  155. 312 rem---print totals
  156. 314 cy=12:cx=3:a=1:gosub318
  157. 316 cx=35:a=0
  158. 318 gosub354:poketc,a
  159. 320 printright$(str$(tl(a)),2)
  160. 322 return
  161. 324 rem---get key
  162. 326 cy=22:gosub348
  163. 328 cx=(40-len(q$))/2:gosub354
  164. 330 poketc,1:printq$;
  165. 332 poke198,0:poke204,0
  166. 334 wait198,15:geta$:z=len(se$)
  167. 336 ifa$=mid$(se$,z,1)then342
  168. 338 z=z-1:ifzthen336
  169. 340 goto334
  170. 342 poke204,1:printa$
  171. 344 fora=1to500:next
  172. 346 rem---clear line
  173. 348 poke214,cy-1:print:printsp$
  174. 350 return
  175. 352 rem---plot
  176. 354 poke214,cy-1:print:printtab(cx);
  177. 356 return
  178. 358 rem---print checkers
  179. 360 cy=2+a*2:cx=8+(aand1)*3:gosub354
  180. 362 forz=0to3
  181. 364 printchr$(18);a$;"$%[157][157][157]*)([145]";
  182. 366 next
  183. 368 return
  184. 370 rem---initialize
  185. 372 printchr$(8)chr$(147)
  186. 374 poke56334,peek(56334)and254
  187. 376 poke1,peek(1)and251
  188. 378 fora=0to511:poke14336+a,peek(53248+a):next
  189. 380 poke1,peek(1)or4
  190. 382 poke56334,peek(56334)or1
  191. 384 poke53272,(peek(53272)and240)or14
  192. 386 fora=0to31:readz:poke14616+a,z:poke14616+63-a,z:next
  193. 388 fora=0to7:poke14616+64+a,peek(14616+a):next
  194. 390 poke53280,7:poke53281,15
  195. 392 poke53282,10:poke53283,2
  196. 394 poke53265,peek(53265)or64
  197. 396 rem---sprite cursors
  198. 398 fora=832to959:pokea,0:next
  199. 400 fora=835to874step3:pokea,192:pokea+2,3:next
  200. 402 fora=0to2:poke832+a,255:poke877+a,255:next
  201. 404 fora=896to943:pokea,255:next
  202. 406 return
  203. 408 rem---character data
  204. 410 data0,0,0,3,7,15,15,31
  205. 412 data0,0,255,255,255,255,255,255
  206. 414 data0,0,0,192,224,240,240,248
  207. 416 data0,0,255,255,255,153,147,135
  208.